//==========================================================================
// Copyright (c) 2000-2008,  Elastos, Inc.  All Rights Reserved.
//==========================================================================
#if _MSC_VER > 1000
#pragma once
#endif

#if !defined(__CMUTEX_H__)
#define __CMUTEX_H__

class CMutex : public IMutex
{
    friend class CCondition;
//  Interface functions
//
public:
    CARAPI_(PInterface) Probe(
                /* [in] */ REIID riid);

    CARAPI_(UInt32) AddRef(void);

    CARAPI_(UInt32) Release(void);

    CARAPI Aggregate(
                /* [in] */ AggrType aggrType,
                /* [in] */ PInterface pObject);

    CARAPI GetDomain(
                /* [out] */ PInterface *ppObject);

    CARAPI Lock(
                /* [out] */ WaitResult *pResult);

    CARAPI TryLock(
                /* [in] */ Millisecond32 msTimeout,
                /* [out] */ WaitResult *pResult);

    CARAPI Unlock();

    virtual ~CMutex() {}
private:
    Interlocked m_cRef;
    DzMutex m_kmutex;
};

#endif //!(__CMUTEX_H__)
